#coding:utf-8

from flask import Flask, request, session
from flask import render_template
from service.orderservice import oservice
from service.userservice import uservice
from controller.usercontroller import uc
from controller.ordercontroller import oc
from model.userinfo import UserInfo
import sys
reload(sys)
sys.setdefaultencoding("utf-8")

app = Flask(__name__, template_folder="html")
app.secret_key = 'ucenter'
app.register_blueprint(uc)
app.register_blueprint(oc)

@app.route("/")
def first():
	user = None
	if "user" in session:
		user = UserInfo()
		user.uname = session["user"]
	res = oservice.get_all_today()
	return render_template("index.html", orderList = res, user=user)

if __name__ == '__main__':
	app.debug = True
	app.run(host="0.0.0.0",port=8080)